<template>
  <div class='wy-main car-info wei_car-info'>
    <a-form :form="form" @submit="handleSubmit" class="wy-form" >
      <a-form-item v-bind="formItemLayout" label="栏目">
            <a-select :disabled="disabled" style="width:280px" placeholder='请选择政策类型' v-decorator="[ 'contentType', { rules: [ {required: true, message: '政策类型不能为空！',}]}]" >
          <!--     <a-select-option key="1" :value="5">公示公告</a-select-option>
              <a-select-option key="2" :value="6" >国内政策</a-select-option>
              <a-select-option key="3" :value="7" >省内政策</a-select-option> -->
                  <a-select-option v-for="(itme,index) in list" :key="index" :value="itme.dictKey">
            {{itme.dictValue}}
          </a-select-option>
            </a-select>
          </a-form-item>
        <a-form-item v-bind="formItemLayout" label="标题">
          <a-input :disabled="disabled" v-decorator="[ 'contentTitle', { rules: [ {required: true, message: '标题不能为空！',}]}]" placeholder='请输入标题（50字以内）'   />
        </a-form-item>
        <a-form-item v-bind="formItemLayout" label="摘要">
          <a-textarea  :disabled="disabled" :autosize="{ minRows: 4, maxRows: 6 }" v-decorator="[ 'contentLabel', { rules: [ {required: true, message: '招标说明不能为空！',}]}]"   placeholder='请输入摘要（200字以内）'/>
        </a-form-item>
        <a-form-item v-bind="formItemLayout" label="发布者">
          <a-input  disabled  v-model="admin1" />
        </a-form-item>
        <a-form-item v-bind="formItemLayout" label="来源">
          <a-input :disabled="disabled" v-decorator="[ 'contentOrigin', { rules: [ {required: true, message: '来源不能为空！',}]}]" placeholder='请输入来源'   />
        </a-form-item>
<!--         <a-form-item v-bind="formItemLayout" label="浏览权限">
        <a-radio-group @change="onChange" v-model="vipp">
          <a-radio :value="1">普通会员</a-radio>
          <a-radio :value="2">物流云会员</a-radio>
        </a-radio-group>
        </a-form-item> -->
      <a-form-item v-bind="formItemLayout" label="内容">
          <div class="textareas">
            <a-textarea   :disabled="disabled" style="width:100%;height:600px;"  v-decorator="[ 'contentTxt', { rules: [ {required: true, message: '内容不能为空！',}]}]"   placeholder='请输入内容（5000字以内）'/>
            </div>
        </a-form-item>
         
      <a-row style="margin-top: 10px;">
        <a-col :span="24">
          <p style="margin: 0;">
            <a-divider style="width: 95%;margin-left: 20px;" />
          </p>
        </a-col>
      </a-row>
        <div class="ant-row ant-form-item"  v-if='type!="info"'>
        <div class="ant-col-4 ant-form-item-label"></div>
        <div class="ant-col-20 ant-form-item-control-wrapper">
          <div class="ant-form-item-control">
            <div class="ant-title">
              <span class="title-span" style="margin-left:-50px; font-size:16px; font-weight:700; ">审核意见</span>
            </div>
             <div class="ant-radio">
            <a-radio-group v-model="value">
              <a-radio :value="107">
              通过
              </a-radio>
              <a-radio :value="108">
              拒绝
              </a-radio>
           </a-radio-group>
           </div>
           <div class="a-textarea">
             <a-textarea placeholder="审核意见" v-model="approvalRemarks" style="margin-top: 10px; width: 447px;height:173px;" :rows="4" />
           </div>
          </div>
        </div>
      </div>
      <div class="ant-row ant-form-item" v-if='type!="info"'>
        <div class="ant-col-4 ant-form-item-label"></div>
        <div class="ant-col-10 ant-form-item-control-wrapper">
          <div class="ant-form-item-control">
            <span class="ant-form-item-children">
              
              <a-button type="primary"  html-type="submit" >
                {{datail.approvalStatus == 107 ? '关闭':'提交'}}
              </a-button>

           <!--    <a-button @click="cancel()">
                取消
              </a-button> -->
              
            </span>
          </div>
        </div>
      </div>
      
    </a-form>
  </div>
</template>
<script>
  import { environment } from '@/environments/environment'
  import {checkTel, checkTelNum, checkEmail} from 'utils/formValidate'
  import {mapState, mapGetters,mapMutations} from 'vuex'
  export default {
    components: {
    },
    props:['datail','type'],
    data() {
      return {
        uploadUrl: environment.FileUploadUrl+'/fileupload/upload',// 图片上传地址
        FileUploadUrl2:environment.FileUploadUrl2,
        loading: false,
        admin1:'',
        disabled:true,
        contentCode:16,
        list:[],
        value:107,
        Driver_img:'',
        approvalRemarks:'',
        vipp:1,
        formItemLayout: {
          labelCol: {
            xs: {
              span: 24
            },
            sm: {
              span: 4
            },
          },
          wrapperCol: {
            xs: {
              span: 24
            },
            sm: {
              span: 10
            },
          },
        },
      }
    },
    beforeCreate() {
      this.form = this.$form.createForm(this);
    },
    created() {
      this.getType(16)
    this.admin1 = this.$store.state.account.user.username;
    
      if(this.datail){
        console.log(this.datail)
        let d = this.datail
        if(d.approvalStatus==107){
          this.value = 108;
        }else{
          this.value = 107;
        }
        this.approvalRemarks = d.approvalRemarks;

        this.form.getFieldDecorator('vipp', { initialValue: 1, preserve: true });
           setTimeout(() => {
          this.form.setFieldsValue({
            contentType:d.contentType,
            contentTitle:d.contentTitle,
            contentLabel:d.contentLabel,
            contentOrigin:d.contentOrigin,
            upload1:this.upload1==true?true:false,
            // coverPath:d.coverPath,
            // coverPic:d.coverPic,
            // vipp:d.vipp,
            contentTxt:d.contentTxt.replace(/<.*?>/g,"")


          })
          }, 100);
      }

    },
    watch: {},

    mounted: function() {

    },
    methods: {
                 // 获取字典类型
      getType(type){
        this.$get('/info/commonDict', {
          dictType: type
        }).then((r) => {
          if(type == 3){
            console.log(r)
          }
          switch(type){
            case 16: this.list = r.data.data.rows; break;
          }
        })
      },

    onChange(e){
        this.vipp = e.target.value;
      },
      cancel(){
         this.$emit('cancel');
      },

            //认证提交
      handleSubmit(e) {
      if(this.datail.approvalStatus == 107){
          this.$emit('cancel');
          return ;
        }
        
        e.preventDefault();
        this.form.validateFieldsAndScroll((err, values) => {
         
          values.contentTxt = this.contentTxt
          // values.vipp = this.vipp
          values.contentCode = this.contentCode
          values.approvalStatus = this.value;
          values.approvalRemarks = this.approvalRemarks
          values.contentId = this.datail.contentId

          if(!err) {

                this.$put('content/content', values,true).then((r) => {
                if(r.status == 200){
                  this.$message.success(r.data.message);
                  this.form.resetFields();
                  this.$emit('cancel');
                }else{
                  this.$message.error(r.data.message);
                }
                this.loading = false;
              }).catch((e) => {
                this.loading = false;
              })


            }

        });
      },
    },
    computed: {
    ...mapState(['setUser'])
    },
  }
</script>

<style lang="less" scoped>
  .car-info {
    .upzjimg{
      .up_img{
        float: left;
        position: relative;
        margin-right: 10px;
        margin-bottom: 10px;
        img{
          width: 200px;
          height: 200px;
        }
        .up_img_d{
          width: 200px;
          height: 200px;
          padding-top: 55px; 
        }
        .img_zz{
          width: 200px;
          height: 200px; 
          position: absolute; 
          color: #fff;
          border: 1px solid;
          .img_zz_text{
            width: 100%;
            text-align: center;
            position: absolute;
            z-index: 10;
            padding-top: 55px; 
          }
          .img_zz_d{
            position: absolute;
            width: 200px ;
            height:200px;
            background: #000;
            opacity:0.6;
          }
        }
      }
    }
  .wei_mi{
    position: absolute;
    right: -30px;
  }
  .wei_lifangmi{
    position: absolute;
    right: -60px;
  }
  }

    .wei_car-info{
     .textareas{
      width: 680px;
     }

    }

</style>